﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;

namespace DelonixRegiaHMSys.UI.WebForms
{
    public partial class GuestReservation : System.Web.UI.Page
    {
        string userID;
        string guestID;
        string a;
        protected void Page_Load(object sender, EventArgs e)
        {
            userID = Request.QueryString["UserID"];
            guestID = Request.QueryString["GuestID"];
            DateTime date = DateTime.Now;
            a = date.ToString("yyyy-MM-dd");
            if (!IsPostBack)
            {
                BindGridView();
            }
        }

        private void BindGridView()
        {
            var rrservice = new rrServices(new EfRoomReservationQuery());
            DateTime b = Convert.ToDateTime(a);
            GridViewReservation.DataSource = rrservice.GetReservationbyGuestID(guestID, b).ToList();
            GridViewReservation.DataBind();
        }

        protected void lblcfar_Click(object sender, EventArgs e)
        {
            string[] arg = new string[9];
            arg = ((LinkButton)sender).CommandArgument.ToString().Split(';');
            string reservationID = arg[0];
            string numOfAdults = arg[1];
            string numOfChildren = arg[2];
            string arrivalDate = arg[3];
            string roomType = arg[4];
            string bedType = arg[5];
            string smokingOrNot = arg[6];
            string addRemarks = arg[7];
            string reservationStatus = arg[8];

            string querystring = "UserID=" + userID + "&GuestID=" + guestID + "&ReservationID=" + reservationID + "&NumOfAdults=" + numOfAdults + "&NumOfChildren=" + numOfChildren + "&RoomType=" + roomType + "&BedType=" + bedType + "&SmokingOrNot=" + smokingOrNot + "&AddRemarks=" + addRemarks + "&ArrivalDate=" + arrivalDate + "&ReservationStatus=" + reservationStatus;
            Server.Transfer("~/WebForms/RRandCIModule/RoomSelectionFromReservation.aspx?" + querystring);
        }
    }
}